package 线程停止;
class mythredd extends Thread
{
	public void run()
	{
		super.run();
		try 
		{
		for(int i=0;i<400000;i++)
		{
			if(this.interrupted())
			{
				System.out.println("已经是停止状态了！我要退出");
			
				throw new InterruptedException();
			}
			System.out.println("i="+(i+1));
		}
		System.out.println("线程未停止");
		
		}
		catch(InterruptedException e)
		{
			System.out.println("进入MyThread.java类run方法中catch了");
			e.printStackTrace();
		}
		

	}
}
public class Test1_37 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			mythredd thread =new mythredd();
			thread.start();
			Thread.sleep(2000);
			thread.interrupt();
			
		} catch (InterruptedException e) {
			// TODO: handle exception
			System.out.println("main catch");
		}
		System.out.println("end!");

	}

}
